package router

import (
	"IrisStandard/response"
	"IrisStandard/util"
	"github.com/kataras/iris"
)

func CheckLoginTokenMiddleware(ctx iris.Context) {
	tokenString := ctx.GetHeader("Authorization")
	userId, err := util.CheckLoginToken(tokenString)
	if err != nil {
		_, _ = ctx.JSON(response.LoginTimeout)
	} else {
		ctx.Header("cached_userId", userId)
		ctx.Next()
	}
}
